package home.actions.main;

import home.actions.base.BaseAction;
import home.db.NoteDAO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by Administrator on 2015/12/10.
 */
public class DelAction extends BaseAction {

    public String execute(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        String cc = req.getParameter("cc");
        if (cc == null || "".equals(cc.trim())) {
            req.getSession().setAttribute("msg", "请选择要删除的笔记");

            return "redirect:index.do";
        } else {
            String[] ccs = cc.split(",");
            for (String id : ccs) {
                if (id != null && !"".equals(id)) {
                    NoteDAO.delNote(id);
                }
            }
            req.getSession().setAttribute("msg", "笔记删除成功");
            return "redirect:index.do";
        }
    }
}
